﻿using System;
using System.Xml;
using System.Data;
using System.IO;

namespace SBPweb.MediaCenter.Common.Data
{
    public abstract class DataSourceBase<T> where T: DataSet
    {

        protected const string PROFILE_FILTER_EXPRESSION = null;
        protected const string PROFILE_SORT_EXPRESSION = "Name";

        protected string pXml;
        protected T pDataSet;

        public DataSourceBase(string sourceXml, T dataSet)
        {
            FileInfo fI = new FileInfo(sourceXml);
            if (!fI.Exists)
            {
                throw new ArgumentException(sourceXml);
            }

            pXml = fI.FullName;
            pDataSet = dataSet;

            Load();
        }

        public void Save()
        {
            pDataSet.WriteXml(pXml);
        }

        public void Load()
        {
            pDataSet.ReadXml(pXml);
        }
    }
}
